package cn.sunxyz.spider.queue.support;


import cn.sunxyz.spider.queue.Queue;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * Created by yangrd on 2018/5/30
 **/
public class DefaultQueue<T> implements Queue<T> {

    private java.util.Queue<T> queue;

    public DefaultQueue() {
        queue = new LinkedBlockingQueue<>();
    }

    public DefaultQueue(int capacity) {
        queue = new LinkedBlockingDeque<>(capacity);
    }

    @Override
    public void push(T t) {
        queue.add(t);
    }

    @Override
    public T pop() {
        return queue.poll();
    }

    @Override
    public int size() {
        return queue.size();
    }
}
